﻿<shared:PageBase x:Class="Bymed.SpineScan.WPF.PatientDataSearchPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:shared="clr-namespace:Bymed.SpineScan.WPF.Shared"
      mc:Ignorable="d" 
      x:Name="CurrentPage"                 
      d:DesignHeight="1000" d:DesignWidth="1280"
	  Title="PatientDataSearchPage" Style="{StaticResource DefaultPageStyle}" Loaded="CurrentPage_Loaded"
      DataContext="{Binding PatientDataSearch, Source={StaticResource Locator}}">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Skins/Storyboard/PageStoryborad.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <!-- Main Content -->
            <RowDefinition Height="Auto" />
            <!-- Navigation Buttons -->
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid>
            <Grid.Background>
                <ImageBrush ImageSource="/Skins/Resource/Image/GrayRightAboveTabBackground.png" />
            </Grid.Background>
            <Grid>
                <Grid.RowDefinitions>
                    <!-- Page Title -->
                    <RowDefinition Height="55" />
                    <!-- Patient Info -->
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock Text="信息检索" Margin="0,15,40,0" HorizontalAlignment="Right" Style="{StaticResource PageTitleTextBlock}" />
                <Grid Grid.Row="1" Margin="20,0,20,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="编号" VerticalAlignment="Center" Style="{StaticResource PatientInfoTextBlock}" />
                        <TextBox Text="{Binding PatientNumber}" Margin="6,0,0,0" Width="160" Height="36" Style="{StaticResource PatientInfoTextBox}" />
                        <TextBlock Text="姓名" Margin="40,0,0,0" VerticalAlignment="Center" Style="{StaticResource PatientInfoTextBlock}" />
                        <TextBox Text="{Binding PatientName}" Margin="6,0,0,0" Width="160" Height="36" Style="{StaticResource PatientInfoTextBox}" />
                        <TextBlock Text="类型" Margin="40,0,0,0" VerticalAlignment="Center" Style="{StaticResource PatientInfoTextBlock}" />
                        <ComboBox x:Name="SelectedDataTypeComoBox" Margin="6,0,0,0" Width="160" Height="36" Background="#fafafa" FontSize="16" 
                                  VerticalContentAlignment="Center" Padding="6,0,0,0">
                            <ComboBoxItem Content="全部" ToolTip="查询全部结果" IsSelected="True" Tag="-1" />
                            <ComboBoxItem Content="未完成测试" ToolTip="所有没有完成测试的" Tag="0" />
                            <ComboBoxItem Content="今日已完成" ToolTip="今天完成测试的" Tag="1" />
                            <ComboBoxItem Content="完成测试" ToolTip="所有已经完成测试的" Tag="2" />
                        </ComboBox>
                        <Button Margin="40,0,0,0" Width="60" Tag="/Skins/Resource/Image/Search.png" 
                                Style="{StaticResource OpacityImageButton}" ToolTip="检索"
                                Command="{Binding SearchCommand}" 
                                CommandParameter="{Binding SelectedValue.Tag, ElementName=SelectedDataTypeComoBox}" />
                    </StackPanel>
                    <Button Width="40" Tag="/Skins/Resource/Image/Delete.png" ToolTip="删除受试者数据"
                                Command="{Binding DeletePatientCommand}" CommandParameter="{Binding SelectedItems, ElementName=DataGridPatients}"
                                Style="{StaticResource OpacityImageButton}" HorizontalAlignment="Right" />
                    <DataGrid x:Name="DataGridPatients" Grid.Row="1" Margin="0,10,10,0" Height="170" 
                              SelectedItem="{Binding SelectedPatient, Mode=OneWayToSource}"
                              ItemsSource="{Binding PatientList}">
                        <DataGrid.Resources>
                            <SolidColorBrush Color="LightBlue" x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" />
                        </DataGrid.Resources>
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="70" Header="顺序号" Binding="{Binding SequenceNumber}" />
                            <DataGridTextColumn Width="170" Header="编号" Binding="{Binding Number}" />
                            <DataGridTextColumn Width="100" Header="姓名" Binding="{Binding Name}" />
                            <DataGridTextColumn Width="70" Header="性别" Binding="{Binding GenderDisplay}" />
                            <DataGridTextColumn Width="100" Header="生日" Binding="{Binding BirthdayDisplay}" />
                            <DataGridTextColumn Width="120" Header="身高（厘米）" Binding="{Binding Height}" />
                            <DataGridTextColumn Width="120" Header="体重（公斤）" Binding="{Binding Weight}" />
                            <DataGridTextColumn Width="*" Header="备注" Binding="{Binding Remark}" />
                            <DataGridTextColumn Width="160" Header="创建日期" Binding="{Binding CreateDateDisplay}" />
                        </DataGrid.Columns>
                    </DataGrid>
                    <StackPanel Grid.Row="2" Margin="0,20,0,0" Orientation="Horizontal">
                        <TextBlock Text="当前查看：" Style="{StaticResource PatientInfoTextBlock}" />
                        <TextBlock Text="{Binding SelectedPatient.Name}" Style="{StaticResource PatientInfoTextBlock}" />
                    </StackPanel>
                    <Button Grid.Row="2" Margin="0,10,0,0" Width="40" Tag="/Skins/Resource/Image/Delete.png" ToolTip="删除测试数据" HorizontalAlignment="Right"
                                Command="{Binding DeleteTestResultCommand}" CommandParameter="{Binding SelectedItems, ElementName=DataGridTestResults}"
                                Style="{StaticResource OpacityImageButton}" />
                    <DataGrid x:Name="DataGridTestResults" Grid.Row="3" Margin="0,10,10,20" Height="170" 
                              ItemsSource="{Binding TestResultList}">
                        <DataGrid.Resources>
                            <SolidColorBrush Color="LightBlue" x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" />
                        </DataGrid.Resources>
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="80" Header="顺序号" Binding="{Binding SequenceNumber}" />
                            <DataGridTemplateColumn Width="80" Header="整体报告">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="查看" Style="{StaticResource LinkButton}" Command="{Binding ShowTestSummaryReportCommand}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTextColumn Width="100" Header="主治医生" Binding="{Binding AttendingDoctor.Name}" />
                            <DataGridTextColumn Width="160" Header="测试日期" Binding="{Binding TestDateDisplay}" />
                            <DataGridTemplateColumn Width="150" Header="躯干倾斜角ATI">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding ScoliosisATI.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding ScoliosisATI}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="脊柱后凸">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding Kyphosis.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding Kyphosis}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="颈椎侧向弯曲">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding CervicalLateralBending.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding CervicalLateralBending}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="胸椎侧向弯曲">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding ThoracicLateralBending.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding ThoracicLateralBending}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="腰椎侧向弯曲">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding LumbarLateralBending.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding LumbarLateralBending}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="颈椎前屈后伸">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding CervicalFlexExt.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding CervicalFlexExt}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="胸椎前屈后伸">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding ThoracicFlexExt.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding ThoracicFlexExt}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="腰椎前屈后伸">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding LumbarFlexExt.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding LumbarFlexExt}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="颈椎水平旋转">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding CervicalRotation.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding CervicalRotation}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="胸椎水平旋转">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding ThoracicRotation.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding ThoracicRotation}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="腰椎水平旋转">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding LumbarRotation.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding LumbarRotation}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="头部平衡">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding HeadBalance.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding HeadBalance}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="肩部平衡">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding ShouldersBalance.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding ShouldersBalance}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="150" Header="髋骨平衡">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="{Binding PelvicBalance.FormattedTestResult}" Style="{StaticResource LinkButton}" 
                                                Command="{Binding ShowSingleTestDetailCommand}" 
                                                CommandParameter="{Binding PelvicBalance}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </Grid>
        </Grid>
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
            <Button Content="上一步" Margin="0,0,120,0" Tag="/Skins/Resource/Image/Back.png" Style="{StaticResource NavigationButton}" Click="ButtonBack_Click" />
            <Button Content="下一步" Tag="/Skins/Resource/Image/Next.png" Style="{StaticResource NavigationButton}" Command="{Binding GoToNextCommand}"  />
        </StackPanel>
    </Grid>
</shared:PageBase>